<template>
    <div claas="search-result">
        <van-list
  v-model:loading="loading"
  :finished="finished"
  finished-text="没有更多了"

  @load="onLoad"
>
  <van-cell v-for="(item, index) in list" :key="index" :title="item.title"  class="cell-item"/>
</van-list>
    </div>
</template>

 
<script setup>
import { reactive, toRefs } from "vue"
import axios from "axios"
import { useUsersStore3 } from "../../store/search"

let store = useUsersStore3()
let ress = reactive({
    list: [],
    loading: false,
    finished: false,
    pafeNum: 1,

})
let { loading, finished, list } = toRefs(ress)
function onLoad() {
    axios.get("/search", { params: { pageNumber: ress.pafeNum, q: store.searchValue } }).then((res) => {
        let results = res.data.list
        ress.list.push(...results)
        ress.loading = false
        if (results.length > 0) {
            ress.pafeNum = res.data.p_num
        } else {
            ress.finished = true
        }
    })


}
</script>

<style scoped>
.cell-item {
    min-height: 200px;
}
</style>